#coding:utf-8
from untils.CSVREADER import EXCEL
from untils.ElementReader import YamlReader
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium import webdriver
# from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC



class BasePage(object):
    """初始化基础页面，初始化获取yaml对象和驱动"""
    def __init__(self,driver):
        # self.yamlreader = YamlReader()
        self.excel = EXCEL("casesdata.xlsx")
        self.driver = driver
        # self.driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
        # self.driver.maximize_window()



    """跳转"""
    def get(self,url):
        self.driver.get(url)

    list=[1,2]
    """获取元素"""
    def find_element(self,list):
        return self.driver.find_element(list[0],list[1])

    def find_elements(self,list):
        return self.driver.find_elements(list[0],list[1])

    def get_handle(self):
        return self.driver.window_handles

    def get_title(self):
        return self.driver.title

    def get_current_url(self):
        return self.driver.current_url

    def handoff_handle(self):
        return self.driver.switch_to.window(self.get_handle()[-1])

    def WebDriver_Wait(self,wait):
        return WebDriverWait(self.driver,20).until(EC.presence_of_element_located(wait))

    def get_pagesource(self):
        return self.driver.page_source

if __name__ == '__main__':
    BasePage(object).excel()